package com.fh.order.controller;


import com.fh.Idempotent.IdemAnnotation;
import com.fh.address.entity.MemberReceiveAddress;
import com.fh.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import utils.ResultObj;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author zs
 * @since 2021-10-21
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @Resource
    private HttpServletRequest request;
    @PostMapping
    @IdemAnnotation
    public ResultObj addOrder(MemberReceiveAddress memberReceiveAddress,Integer payType, BigDecimal totalMoney){
        String phone = request.getHeader("phone");
        String orderSn = orderService.createOrder(memberReceiveAddress, payType, phone, totalMoney);
        return  ResultObj.success(orderSn);
    }


}
